package s2_threadApi;
/*
* 线程的常见方法
* */
class MyRunnable implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 5; i++){
            System.out.println(Thread.currentThread().getName());
        }
    }
}
public class NameSetTest {
    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable(),"线程1");
        Thread t1 = new Thread(new  MyRunnable(),"线程2");

        t.start();
        t1.start();
//        t.setName("线程1111111111111111");//这个方法在start后面时，当主线程很慢的时候，不会覆盖[很少的情况]
        System.out.println(t.getName());
        System.out.println(t1.getName());
        String name = Thread.currentThread().getName();
        System.out.println(name);//主线程默认的名字：main
    }

}
